//
//  FRPFullSizePhotoViewModel.m
//  FunctionalReactivePixels
//
//  Created by sun on 15/7/15.
//  Copyright (c) 2015年 sunfei. All rights reserved.
//

#import "FRPFullSizePhotoViewModel.h"
#import "FRPPhotoModel.h"

@interface FRPFullSizePhotoViewModel ()

@property (nonatomic) NSInteger initialPhotoIndex;

@end

@implementation FRPFullSizePhotoViewModel

- (instancetype)initWithPhotoArray:(NSArray *)photoArray
                 initialPhotoIndex:(NSInteger)initialPhotoIndex {
    self = [super initWithModel:photoArray];
    if (self) {
        self.initialPhotoIndex = initialPhotoIndex;
    }
    return self;
}

- (NSString *)initialPhotoName {
    return [[self photoModelAtIndex:self.initialPhotoIndex] photoName];
}

- (FRPPhotoModel *)photoModelAtIndex:(NSInteger)index {
    if (index < 0 || index > self.model.count - 1) {
        return nil;
    } else {
        return self.model[index];
    }
}

@end
